﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddOrEdit.aspx.cs" Inherits="admin_Modules_Common_Config_AddOrEdit"
    EnableViewState="false" EnableEventValidation="false" ValidateRequest="false" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/ADMIN/resources/css/Product_AddEdit.css" rel="stylesheet" type="text/css" />
    <script src="/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/config.js" type="text/javascript"></script>
    <script src="/plugins/ckeditor/config.js" type="text/javascript"></script>
    <script src="/admin/resources/js/base.js" type="text/javascript"></script>
    <script src="/admin/resources/js/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="/admin/resources/js/jquery.MultiFile.js" type="text/javascript"></script>
    <script type="text/javascript">
        function loadEditor() {
            var oFCKeditor = CKEDITOR.replace('fckHtmlEditor', {
                customConfig: '/plugins/ckeditor/config.js',
                filebrowserBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserImageBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserFlashBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Flash',
                filebrowserUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files',
                filebrowserImageUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
                filebrowserFlashUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'

            });

            oFCKeditor.BasePath = '/plugins/ckeditor/';
            oFCKeditor.Width = '680px';
            oFCKeditor.Skin = 'v2';
            oFCKeditor.Height = '250px';

            //CKFinder.setupCKEditor(oFCKeditor, { basePath: '/ckfinder/', rememberLastFolder: false });

        }

        var getFckText = function () {
            return CKEDITOR.instances.fckHtmlEditor.getData();

        }

        var setFckText = function () {
           // alert(hdfPlainText.getValue());
           // CKEDITOR.instances.fckHtmlEditor.insertText(hdfPlainText.getValue());
        }

        var reLoadDataWithType = function (type) {
            switch (type) {
                case 'loadfile':
                    Ext.net.DirectMethods.LoadFile({
                        success: function () {
                            //reLoad();
                            //alert("xxx");
                        },
                        failure: function (errorMsg) {
                            Ext.Msg.alert('Failure', errorMsg);
                        }
                    });
                    break;
                case 'loadtree':
                    reLoad();
                    break;
            }
        }
        var managerFiles = function () {
            url = 'Modules/shoppingcart/UploadFile/Default.aspx';
            title = "Quản lí ảnh của sản phẩm";
            window.top.newWindow(url, { title: title, height: 600, width: 600, modal: true });
        }
        var removediv = function (id) {
            var div = Ext.get(id);
            div.remove();
            //alert(id);
            var strID = id.replaceAll('divfile', '');
            var listIndex = hdfListRemoveAtt.getValue();
            hdfListRemoveAtt.setValue(listIndex + strID + ',');
            alert(strID);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server">
        <Listeners>
            <DocumentReady Handler="loadEditor();setFckText();" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Hidden ID="hdfPlainText" runat="server" Text="" />
    <ext:Viewport ID="ViewPort2" runat="server" Layout="BorderLayout">
        <Items>
            <ext:Panel ID="pnConfig" runat="server" Frame="false" AutoScroll="true" Border="false"
                Region="Center" BodyBorder="false">
                <TopBar>
                    <ext:Toolbar>
                        <Items>
                            <ext:Button ID="btnSave" runat="server" Text="Cập nhật" Icon="Disk">
                                <DirectEvents>
                                    <Click OnEvent="OnSave" Before="valid = #{StatusForm}.getForm().isValid() ;  return valid;">
                                        <ExtraParams>
                                            <ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:FormPanel runat="server" Border="false" ID="StatusForm" Padding="5">
                        <Items>
                            <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="100">
                                <Anchors>
                                    <ext:Anchor>
                                        <ext:TextField AllowBlank="false" runat="server" ID="txtKey" FieldLabel="Key" Width="400" AnchorHorizontal="50%">
                                        </ext:TextField>
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField runat="server" ID="txtDescription" FieldLabel="Mô tả" Width="400" AllowBlank="false"
                                            AnchorHorizontal="50%">
                                        </ext:TextField>
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextArea  ID="fckHtmlEditor" Name="fckHtmlEditor" runat="server" FieldLabel="Giá trị">
                                        </ext:TextArea>
                                    </ext:Anchor>
                                </Anchors>
                            </ext:FormLayout>
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
